<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html id="htmlId">
<head>
    <title>Coverage Report :: LevelTest</title>
    <style type="text/css">
        @import "../../.css/coverage.css";
    </style>
</head>

<body>
<div class="header"></div>

<div class="content">
    <div class="breadCrumbs">
        [ <a href="../../index.html">all classes</a> ]
        [ <a href="../index.html">nl.tudelft.jpacman.level</a> ]
    </div>

    <h1>Coverage Summary for Class: LevelTest (nl.tudelft.jpacman.level)</h1>

    <table class="coverageStats">
        <tr>
            <th class="name">Class</th>
            <th class="coverageStat
">
                Class, %
            </th>
            <th class="coverageStat
">
                Method, %
            </th>
            <th class="coverageStat
">
                Line, %
            </th>
        </tr>
        <tr>
            <td class="name">LevelTest</td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 1)
  </span>
            </td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 10)
  </span>
            </td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 36)
  </span>
            </td>
        </tr>

    </table>

    <br/>
    <br/>


    <div class="sourceCode"><i>1</i>&nbsp;package nl.tudelft.jpacman.level;
        <i>2</i>&nbsp;
        <i>3</i>&nbsp;import static org.assertj.core.api.Assertions.assertThat;
        <i>4</i>&nbsp;
        <i>5</i>&nbsp;import static org.mockito.Mockito.mock;
        <i>6</i>&nbsp;import static org.mockito.Mockito.times;
        <i>7</i>&nbsp;import static org.mockito.Mockito.verify;
        <i>8</i>&nbsp;import static org.mockito.Mockito.when;
        <i>9</i>&nbsp;import nl.tudelft.jpacman.board.Board;
        <i>10</i>&nbsp;import nl.tudelft.jpacman.board.Square;
        <i>11</i>&nbsp;import nl.tudelft.jpacman.npc.Ghost;
        <i>12</i>&nbsp;
        <i>13</i>&nbsp;import com.google.common.collect.Lists;
        <i>14</i>&nbsp;import org.junit.jupiter.api.BeforeEach;
        <i>15</i>&nbsp;import org.junit.jupiter.api.Test;
        <i>16</i>&nbsp;
        <i>17</i>&nbsp;/**
        <i>18</i>&nbsp; * Tests various aspects of level.
        <i>19</i>&nbsp; *
        <i>20</i>&nbsp; * @author Jeroen Roosen
        <i>21</i>&nbsp; */
        <i>22</i>&nbsp;// The four suppress warnings ignore the same rule, which results in 4 same string literals
        <i>23</i>&nbsp;@SuppressWarnings({&quot;PMD.AvoidDuplicateLiterals&quot;, &quot;PMD.TooManyStaticImports&quot;})
        <b class="nc"><i>24</i>&nbsp;class LevelTest {</b>
        <i>25</i>&nbsp;
        <i>26</i>&nbsp; /**
        <i>27</i>&nbsp; * The level under test.
        <i>28</i>&nbsp; */
        <i>29</i>&nbsp; private Level level;
        <i>30</i>&nbsp;
        <i>31</i>&nbsp; /**
        <i>32</i>&nbsp; * An NPC on this level.
        <i>33</i>&nbsp; */
        <b class="nc"><i>34</i>&nbsp; private final Ghost ghost = mock(Ghost.class);</b>
        <i>35</i>&nbsp;
        <i>36</i>&nbsp; /**
        <i>37</i>&nbsp; * Starting position 1.
        <i>38</i>&nbsp; */
        <b class="nc"><i>39</i>&nbsp; private final Square square1 = mock(Square.class);</b>
        <i>40</i>&nbsp;
        <i>41</i>&nbsp; /**
        <i>42</i>&nbsp; * Starting position 2.
        <i>43</i>&nbsp; */
        <b class="nc"><i>44</i>&nbsp; private final Square square2 = mock(Square.class);</b>
        <i>45</i>&nbsp;
        <i>46</i>&nbsp; /**
        <i>47</i>&nbsp; * The board for this level.
        <i>48</i>&nbsp; */
        <b class="nc"><i>49</i>&nbsp; private final Board board = mock(Board.class);</b>
        <i>50</i>&nbsp;
        <i>51</i>&nbsp; /**
        <i>52</i>&nbsp; * The collision map.
        <i>53</i>&nbsp; */
        <b class="nc"><i>54</i>&nbsp; private final CollisionMap collisions = mock(CollisionMap.class);</b>
        <i>55</i>&nbsp;
        <i>56</i>&nbsp; /**
        <i>57</i>&nbsp; * Sets up the level with the default board, a single NPC and a starting
        <i>58</i>&nbsp; * square.
        <i>59</i>&nbsp; */
        <i>60</i>&nbsp; @BeforeEach
        <i>61</i>&nbsp; void setUp() {
        <b class="nc"><i>62</i>&nbsp; final long defaultInterval = 100L;</b>
        <b class="nc"><i>63</i>&nbsp; level = new Level(board, Lists.newArrayList(ghost), Lists.newArrayList(</b>
        <i>64</i>&nbsp; square1, square2), collisions);
        <b class="nc"><i>65</i>&nbsp; when(ghost.getInterval()).thenReturn(defaultInterval);</b>
        <i>66</i>&nbsp; }
        <i>67</i>&nbsp;
        <i>68</i>&nbsp; /**
        <i>69</i>&nbsp; * Validates the state of the level when it isn&#39;t started yet.
        <i>70</i>&nbsp; */
        <i>71</i>&nbsp; @Test
        <i>72</i>&nbsp; void noStart() {
        <b class="nc"><i>73</i>&nbsp; assertThat(level.isInProgress()).isFalse();</b>
        <i>74</i>&nbsp; }
        <i>75</i>&nbsp;
        <i>76</i>&nbsp; /**
        <i>77</i>&nbsp; * Validates the state of the level when it is stopped without starting.
        <i>78</i>&nbsp; */
        <i>79</i>&nbsp; @Test
        <i>80</i>&nbsp; void stop() {
        <b class="nc"><i>81</i>&nbsp; level.stop();</b>
        <b class="nc"><i>82</i>&nbsp; assertThat(level.isInProgress()).isFalse();</b>
        <i>83</i>&nbsp; }
        <i>84</i>&nbsp;
        <i>85</i>&nbsp; /**
        <i>86</i>&nbsp; * Validates the state of the level when it is started.
        <i>87</i>&nbsp; */
        <i>88</i>&nbsp; @Test
        <i>89</i>&nbsp; void start() {
        <b class="nc"><i>90</i>&nbsp; level.start();</b>
        <b class="nc"><i>91</i>&nbsp; assertThat(level.isInProgress()).isTrue();</b>
        <i>92</i>&nbsp; }
        <i>93</i>&nbsp;
        <i>94</i>&nbsp; /**
        <i>95</i>&nbsp; * Validates the state of the level when it is started then stopped.
        <i>96</i>&nbsp; */
        <i>97</i>&nbsp; @Test
        <i>98</i>&nbsp; void startStop() {
        <b class="nc"><i>99</i>&nbsp; level.start();</b>
        <b class="nc"><i>100</i>&nbsp; level.stop();</b>
        <b class="nc"><i>101</i>&nbsp; assertThat(level.isInProgress()).isFalse();</b>
        <i>102</i>&nbsp; }
        <i>103</i>&nbsp;
        <i>104</i>&nbsp; /**
        <i>105</i>&nbsp; * Verifies registering a player puts the player on the correct starting
        <i>106</i>&nbsp; * square.
        <i>107</i>&nbsp; */
        <i>108</i>&nbsp; @Test
        <i>109</i>&nbsp; @SuppressWarnings(&quot;PMD.JUnitTestsShouldIncludeAssert&quot;)
        <i>110</i>&nbsp; void registerPlayer() {
        <b class="nc"><i>111</i>&nbsp; Player p = mock(Player.class);</b>
        <b class="nc"><i>112</i>&nbsp; level.registerPlayer(p);</b>
        <b class="nc"><i>113</i>&nbsp; verify(p).occupy(square1);</b>
        <i>114</i>&nbsp; }
        <i>115</i>&nbsp;
        <i>116</i>&nbsp; /**
        <i>117</i>&nbsp; * Verifies registering a player twice does not do anything.
        <i>118</i>&nbsp; */
        <i>119</i>&nbsp; @Test
        <i>120</i>&nbsp; @SuppressWarnings(&quot;PMD.JUnitTestsShouldIncludeAssert&quot;)
        <i>121</i>&nbsp; void registerPlayerTwice() {
        <b class="nc"><i>122</i>&nbsp; Player p = mock(Player.class);</b>
        <b class="nc"><i>123</i>&nbsp; level.registerPlayer(p);</b>
        <b class="nc"><i>124</i>&nbsp; level.registerPlayer(p);</b>
        <b class="nc"><i>125</i>&nbsp; verify(p, times(1)).occupy(square1);</b>
        <i>126</i>&nbsp; }
        <i>127</i>&nbsp;
        <i>128</i>&nbsp; /**
        <i>129</i>&nbsp; * Verifies registering a second player puts that player on the correct
        <i>130</i>&nbsp; * starting square.
        <i>131</i>&nbsp; */
        <i>132</i>&nbsp; @Test
        <i>133</i>&nbsp; @SuppressWarnings(&quot;PMD.JUnitTestsShouldIncludeAssert&quot;)
        <i>134</i>&nbsp; void registerSecondPlayer() {
        <b class="nc"><i>135</i>&nbsp; Player p1 = mock(Player.class);</b>
        <b class="nc"><i>136</i>&nbsp; Player p2 = mock(Player.class);</b>
        <b class="nc"><i>137</i>&nbsp; level.registerPlayer(p1);</b>
        <b class="nc"><i>138</i>&nbsp; level.registerPlayer(p2);</b>
        <b class="nc"><i>139</i>&nbsp; verify(p2).occupy(square2);</b>
        <i>140</i>&nbsp; }
        <i>141</i>&nbsp;
        <i>142</i>&nbsp; /**
        <i>143</i>&nbsp; * Verifies registering a third player puts the player on the correct
        <i>144</i>&nbsp; * starting square.
        <i>145</i>&nbsp; */
        <i>146</i>&nbsp; @Test
        <i>147</i>&nbsp; @SuppressWarnings(&quot;PMD.JUnitTestsShouldIncludeAssert&quot;)
        <i>148</i>&nbsp; void registerThirdPlayer() {
        <b class="nc"><i>149</i>&nbsp; Player p1 = mock(Player.class);</b>
        <b class="nc"><i>150</i>&nbsp; Player p2 = mock(Player.class);</b>
        <b class="nc"><i>151</i>&nbsp; Player p3 = mock(Player.class);</b>
        <b class="nc"><i>152</i>&nbsp; level.registerPlayer(p1);</b>
        <b class="nc"><i>153</i>&nbsp; level.registerPlayer(p2);</b>
        <b class="nc"><i>154</i>&nbsp; level.registerPlayer(p3);</b>
        <b class="nc"><i>155</i>&nbsp; verify(p3).occupy(square1);</b>
        <i>156</i>&nbsp; }
        <i>157</i>&nbsp;}
    </div>
</div>

<div class="footer">

    <div style="float:right;">generated on 2023-04-25 16:45</div>
</div>
</body>
</html>
